﻿using Abp.Application.Services.Dto;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Choucius.Boilerplate9.Devices;
using Choucius.Boilerplate9.Controllers;
using Abp.AspNetCore.Mvc.Authorization;
using Choucius.Boilerplate9.Authorization;

namespace Choucius.Boilerplate9.Web.Controllers
{
    [AbpMvcAuthorize(PermissionNames.Pages_Users)]
    public class DevicesController : Boilerplate9ControllerBase
    {
        private readonly IDeviceAppService _deviceAppService;

        public DevicesController(IDeviceAppService deviceAppService)
        {
            _deviceAppService = deviceAppService;
        }

        public IActionResult Index()
        {
            return View();
        }

        public async Task<ActionResult> EditModal(int deviceId)
        {
            var deviceDto = await _deviceAppService.GetAsync(new EntityDto<int>(deviceId));
            return PartialView("_EditModal", deviceDto);
        }
    }
}
